package com.smu.recognize.controller.adminController;

import com.smu.recognize.model.Admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static com.smu.recognize.controller.adminController.CommonAction.getUserFromSession;

@Controller
public class LayuiController {
    @RequestMapping("/layui")
    public ModelAndView getLayout(HttpServletRequest request, HttpServletResponse response){
        Admin user = getUserFromSession(request);
        if (user == null) {
            try {
                response.sendRedirect(request.getContextPath() + ""); // 重定向至登录页
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return new ModelAndView("layui");
    }
}
